package com.example.demo.controller;

import com.example.demo.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 马拉圈
 * Date: 2023-08-09
 * Time: 3:17
 */
@RestController
public class TestController2 {
    @RequestMapping("/return_file")
    public Integer returnFile() {
        return 1;
    }

    @RequestMapping("/return_own_json")
    public String returnOwnJson() {
        return "{\"a\":1,\"b\":2}";
    }
    @RequestMapping("/return_html")
    public String returnHtml() {
        return "<h1>哈哈哈</h1>";
    }
    @RequestMapping("/return_id")
    public int returnId() {
        int id = 666;
        return id;
    }

    @RequestMapping("/return_user")
    public User returnUser() {
        return new User(666, "大帅哥");
    }

    @RequestMapping("/return_users")
    public List<User> returnUsers() {
        return new ArrayList<User>() {
            {
                add(new User(666, "大帅哥"));
            }
        };
    }
    @RequestMapping("/return_non")
    public void returnNon() {

    }


}
